package controllers;

import java.util.ArrayList;
import java.util.List;

import play.libs.Json;
import models.Repairrequest;
import models.statistic.StatisticVehicleAndNoticeModel;
import models.statistic.StatisticVehicleModel;
import play.mvc.*;;

public class StatisticVehicle extends Controller {
	public static Result get() {
		StatisticVehicleAndNoticeModel model = calculateStatistic();		
		return ok(Json.toJson(model));
	}
	

	public static StatisticVehicleAndNoticeModel calculateStatistic() {
		StatisticVehicleAndNoticeModel model = new StatisticVehicleAndNoticeModel();
		StatisticVehicleModel vmodel = new StatisticVehicleModel();
		int onRepair = Repairrequest.find.where().isNull("status").findRowCount();
		vmodel.setOnRepair(onRepair);
		int toRepair = 0;
		vmodel.setRepairThisWeek(toRepair);
		int repaired = 0;
		vmodel.setRepaired(repaired);
		int policeCheck = 0;
		vmodel.setPoliceCheck(policeCheck);
		int outofTime = 0;
		vmodel.setOutofTime(outofTime);
		int opCheck = 0;
		vmodel.setOpCheck(opCheck);
		model.setVehicle_status(vmodel);
		
		
		List<String> notices = new ArrayList<String>();
		notices.add("这是一条测试用通知.");
		model.setSafecheck_notices(notices);
		
		return model;
	}
}
